﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Weibo4SharpWeb.Controllers
{
    public class AtMeController : WeiboControllerBase
    {
        //
        // GET: /AtMe/{pageId = 1}

        public ActionResult Index(int id = 1)
        {
            var service = GetAuthenticatedService();
            var mentions = service.ListWeibosMentioningMe(id, 20);

            service.ListWeiboCountsBindToWeibos(mentions);

            ViewBag.PageId = id;
            ViewBag.HasPrev = id > 1;
            ViewBag.HasNext = mentions.Count() == 20;

            if (id == 1)
            {
                service.ResetCount(2);
            }

            if (Request.IsAjaxRequest())
            {
                return PartialView("MentionList", mentions);
            }

            return View(mentions);
        }

    }
}
